<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style type="text/css">
        td{
            padding: 2px 0px;
            text-align: left;
            border: 1px solid #999;
        }
    </style>
    <script src="/resources/js/jquery-1.11.1.min.js"></script>
    <script src="/resources/js/self.js"></script>
    <script type="text/javascript" src="/resources/js/md5.js"></script>
    <script type="text/javascript" src="/resources/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript" src="/resources/js/ajaxfileupload.js"></script>
    <script type="text/javascript" src="/resources/js/Util.js"></script>
    <script type="text/javascript" src="/resources/js/idCardUtil.js"></script>
</head>
<body>
<input type="hidden" id="id" name="id"
       class="form-control form-data ">
<input type="hidden" id="companyId" name="companyId"
       class="form-control form-data ">
<table>
    <tr>
        <td colspan="11">
            <button onclick="back()" class="btn btn-primary" type="button" style="float:right;margin-right:20px;">返回</button>
        </td>
    </tr>
    <tr>
        <td width="11%"><span style="color: red">*</span>姓名</td>
        <td width="11%">
            <input type="text" id="name" name="name"
                   class="form-control form-data ">
        </td>
        <td width="11%">
            别名
        </td>
        <td width="11%">
            <input type="text" id="alias" name="alias"
                   class="form-control form-data ">
        </td>
        <td width="11%">
            <span style="color: red">*</span>性别
        </td>
        <td width="11%">
            <select name="sex" id="sex" class="form-control form-data">
                <option value="secrecy">保密</option>
                <option value="man">男</option>
                <option value="woman">女</option>
            </select>
        </td>
        <td width="11%">
            出生年月
        </td>
        <td width="11%">
            <input type="text" id="brithday" name="brithday" class="form-control form-data"
                   onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})">
        </td>
        <td width="12%" rowspan="5">
            <img id="imgHeadImg"
                 style="height:160px;width: 150px;"
                 src="/resources/images/user_pic-225x225.png"   />

        </td>
    </tr>
    <tr>
        <td>
            文化程度
        </td>
        <td>
            <select name="educationLevel" id="educationLevel" class="form-control form-data">
                <option value="level0">小学以下</option>
                <option value="level1">小学</option>
                <option value="level2">初中</option>
                <option value="level3">中专/高中</option>
                <option value="level4">专科</option>
                <option value="level5">本科</option>
                <option value="level6">硕士</option>
                <option value="level7">博士</option>
            </select>
        </td>
        <td>
            民族
        </td>
        <td>
            <input type="text" id="ethnic" name="ethnic"
                   class="form-control form-data ">
        </td>
        <td>
            工作性质
        </td>
        <td>
            <input type="text" id="natureOfWork" name="natureOfWork"
                   class="form-control form-data ">
        </td>
        <td>
            从业时间
        </td>
        <td>
            <input type="text" id="workYears" name="workYears" class="form-control form-data"
                   onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})">
        </td>
    </tr>
    <tr>
        <td rowspan="1">
            籍贯
        </td>
        <td rowspan="1" colspan="7">
            <input type="text" id="nativePlace" name="nativePlace"
                   class="form-control form-data ">
        </td>

    </tr>
    <tr>
        <td colspan="1">
            户籍地址
        </td>
        <td colspan="7">
            <input type="text" id="nativeAddress" name="nativeAddress"
                   class="form-control form-data ">
        </td>
    </tr>
    <tr>

        <td colspan="1">
            现在住址
        </td>
        <td colspan="7">
            <input type="text" id="address" name="address"
                   class="form-control form-data ">
        </td>
    </tr>
    <tr>
        <td>人员类型</td>
        <td colspan="6">
            <input type="checkbox" value="true" id="securityPeople" name="securityPeople"> <span style="padding-left:5px ">保卫人员</span>
            <input type="checkbox" value="true" id="securityMainPeople" name="securityMainPeople"> <span style="padding-left:5px ">保卫负责人</span>
            <input type="checkbox" value="true" id="purchasePeople" name="purchasePeople"> <span style="padding-left:5px ">采购人员</span>
            <input type="checkbox" value="true" id="purchaseMainPeople" name="purchaseMainPeople"> <span style="padding-left:5px ">采购负责人</span>
            <input type="checkbox" value="true" id="seller" name="seller"> <span style="padding-left:5px ">销售人员</span>
            <input type="checkbox" value="true" id="mainSeller" name="mainSeller"> <span style="padding-left:5px ">销售负责人</span>
            <input type="checkbox" value="true" id="otherPeople" name="otherPeople"> <span style="padding-left:5px ">其他</span>
        </td>
        <td>状态</td>
        <td  >
           <input type="radio" class="form-data form-control" style="display: inline;" name="status" value="valid"  /> 在职
            <input type="radio" class="form-data form-control" style="display: inline;" name="status" value="invalid"/>离职
        </td>

    </tr>
    <tr>
        <td>
            服务单位
        </td>
        <td colspan="3">
            <input type="text" id="company" name="company"
                   class="form-control form-data ">
        </td>

        <td>
            <span style="color: red">*</span> 现在职务
        </td>
        <td colspan="4">
            <input type="text" id="position" name="position"
                   class="form-control form-data ">
        </td>


    </tr>

    <tr>
        <td>
            政治面貌
        </td>
        <td colspan="3">
            <input type="text" id="roleForPolitical" name="roleForPolitical"
                   class="form-control form-data ">
        </td>
        <td >
            <span style="color: red">*</span>联系方式
        </td>
        <td colspan="4" >
            <input type="text" id="telephone" name="telephone"
                   class="form-control form-data ">
        </td>
    </tr>
    <tr>
        <td>
            <span style="color: red">*</span>身份证号
        </td>
        <td colspan="3">
            <input type="text" id="idCard" name="idCard"
                   data-type="idCard"
                   class="form-control form-data ">
        </td>
        <td>
            暂住证号
        </td>
        <td colspan="4">
            <input type="text" id="tempLiveNo" name="tempLiveNo"
                   class="form-control form-data ">
        </td>
    </tr>
    <tr>
        <td rowspan="2">
            资格证书
        </td>
        <td colspan="2">
            颁发机构
        </td>
        <td colspan="2">
            <input type="text" id="authorizedUnit" name="authorizedUnit"
                   class="form-control form-data ">
        </td>
       <!-- <td rowspan="2">
            <button class="btn btn-primary" onclick="$('#file_input').click();" >
                上传文件
            </button>
        </td>-->
        <td rowspan="2" colspan="4">
            <div  id="file_div" style="margin-top: 20px;" >
            </div>
            <input type="file" id="file_input" name="file" onchange="uploadFile('file')" value="Upload your resume"
                   style="opacity: 0;width: 0px;display: none">

        </td>

    </tr>
    <tr>
        <td colspan="2">
            编号
        </td>
        <td colspan="2">
            <input type="text" id="authorizedNo" name="authorizedNo"
                   class="form-control form-data ">
        </td>
    </tr>
    <tr>
        <td rowspan="1" id="zy_family_rowspan">
            主要家庭成员
        </td>
        <td colspan="2">
            姓名
        </td>
        <td colspan="2">
            年龄
        </td>
        <td colspan="2">
            称谓
        </td>
        <td colspan="2">
            身份证号码
        </td>
    </tr>

    <tr class="family-content-after">
        <td>
            何时何地受过何种奖励、处分
        </td>
        <td colspan="8">
            <textarea class="form-control form-data" name="assess" rows="3" placeholder=""></textarea>
        </td>
    </tr>
    <tr>
        <td>
            何时何地参加过何种业务培训
        </td>
        <td  colspan="8">
            <textarea class="form-control form-data" name="training" rows="3" placeholder=""></textarea>
        </td>
    </tr>
    <tr>
        <td>
            简历
        </td>
        <td  colspan="8">
            <textarea class="form-control form-data" name="resume" rows="3" placeholder=""></textarea>
        </td>
    </tr>
    <tr>
        <td>
            备注
        </td>
        <td  colspan="8">
            <textarea class="form-control form-data" name="remark" rows="3" placeholder=""></textarea>
        </td>
    </tr>

    <!--<tr>-->

        <!--<td colspan="9">-->
            <!--<button onclick="back()" class="btn btn-primary" type="button">返回</button>-->
        <!--</td>-->
    <!--</tr>-->

</table>
</body>
<script type="text/javascript">
    $(function () {
        setTitle("基本信息>企业信息>从业人员");
        initData();

    });

    function initData(){
        var data = getData();
        var id = data.id;
        var companyId = data.companyId;
        $("input[name='companyId']").val(companyId);
        if(null2empty(id) !==""){
            $("input[name='id']").val(id);
            $.ajax({
                url:"/admin/practitioner/find.do",
                data:{'id':id},
                type:'post',
                dataType:'json',
                success:function(data){
                    console.log(data);
                    if(data.success){
                        initPageDate(data.data, '.form-data');
                        addFileInfoToTable(data.data.fileInfoList,'file');

                        var familyJson = data.data.familyJson;
                        if(!isNullOrUndefined(familyJson)){
                            var familys = JSON.parse(familyJson);
                            var html = "";
                            $(".family-content").remove();
                            $(familys).each(function (index,item) {
                                var rName =  item.rName;
                                var rAge = item.rAge;
                                var rCall = item.rCall;
                                var rIdCard = item.rIdCard;
                                html = html + '<tr class="family-content">'+
                                        '<td colspan="2"><input type="text" name="rName" value="'+rName+'" class="form-control form-data "></td>'+
                                        '<td colspan="2"><input type="text" name="rAge" readonly class="form-control "></td>'+
                                        '<td colspan="2"><input type="text" name="rCall" value="'+rCall+'" class="form-control form-data "></td>'+
                                        '<td colspan="2"><input type="text"  name="rIdCard" value="'+rIdCard+'" data-type="idCard" for-age="rAge" class="form-control form-data "></td>'+
                                        '</tr>';
                            });

                            $(html).insertBefore(".family-content-after");
                            czZyFamilyRowspan();
                        }


                        $("#imgHeadImg").attr("src",data.data.photo);

                        if(data.data.securityPeople == "valid") {
                            $("#securityPeople").prop("checked", "checked");
                        }
                        if(data.data.securityMainPeople == "valid") {
                            $("#securityMainPeople").prop("checked", "checked");
                        }
                        if(data.data.purchasePeople == "valid") {
                            $("#purchasePeople").prop("checked", "checked");
                        }
                        if(data.data.purchaseMainPeople == "valid") {
                            $("#purchaseMainPeople").prop("checked", "checked");
                        }
                        if(data.data.seller == "valid") {
                            $("#seller").prop("checked", "checked");
                        }
                        if(data.data.mainSeller == "valid") {
                            $("#mainSeller").prop("checked", "checked");
                        }
                        if(data.data.otherPeople == "valid") {
                            $("#otherPeople").prop("checked", "checked");
                        }
                    }
                }
            });
            $("#account").attr('readonly','readonly');
        }
    }

    function back() {
        var companyId = $("input[name='companyId']").val();
        goto("practitioner_list.html",{"companyId":companyId});
    }

    function addFileInfoToTable(fileInfoList,fileType){
        $(fileInfoList).each(function(index,file){
            var fileHtml = "<div  style='border-radius: 2px; width:100%;height:100px;float: left; border: 2px #ffffff solid;'>"+

                    "<div align='center' style='height:80px;margin-bottom: 0px;'>"+
                    "<div align='center' onclick='downLoadFile(\""+file.path+"\",\""+file.name+"\")' ><input type='hidden' name='"+fileType+"_id' value='"+file.id+"'>"+file.name+"</div>"+

                    "<button  style='margin-left: 20px;' " +
                    "onclick='downLoadFile(\""+file.path+"\",\""+file.name+"\")' " +
                    "name='download' extendData='"+file.id+"'class='btn btn-primary'>下载</button>"+
//                    "<button  style='margin-left: 20px;' name='delete' extendData='"+file.id+"'class='btn btn-primary'>删除</button><div>"
            "</div>";
            $("#"+fileType+"_div").html(fileHtml);

        });
        $("button[name='delete']").unbind('click');
        $("button[name='delete']").click(function(){
            var id = $(this).attr("extendData");
            $.ajax({
                type: "POST",
                url: "/file/delete.do?_t=" + new Date().getTime(),
                data: "fileId=" + id,

                success: function (result) {
                    alert("删除成功");
                },

                error: function (XMLHttpRequest, textStatus, thrownError) {
                    /* alert("系统异常");*/
                }
            });
            $(this).parent().parent().remove();
        });
    }
    function setImg(url){
        $("#imgHeadImg").attr('src',url);
        $("#headImg").val(url);
    }
    function downLoadFile(url,name) {
        var $a = $("<a></a>").attr("href", url).attr("download", name);
        $a[0].click();
    }


    function czZyFamilyRowspan() {
        var size = $(".family-content").length;
        $("#zy_family_rowspan").attr("rowspan", size + 1);
    }

</script>
</html>